home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte24 / ex2.c < prev    next >
C/C++ Source or Header  |  1995-07-04  |  2KB  |  45 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.        case WM_COMMAND:
  8.                switch ( LOWORD( wParam ) )
  9.                {
  10.                    case IDM_TEST:
  11.                    {                       // Try to create 32K timers.
  12.                       int i;
  13.                       int iInterval = 500;    // Start at 500 milliseconds
  14.                       for (i=0; i<0x7fff; i++)
  15.                       {
  16.                          int result = SetTimer( hWnd, i+1, iInterval, NULL );
  17.                          if ( !result )  // If we cannot create the timer.
  18.                          {
  19.                              TCHAR szErrMsg[128];
  20.                              // KillTimer frees a timer for screen capture utility.
  21.                              // This allows the message box to be captured. Note:
  22.                              // timers are _system-wide_ resources.
  23.                              KillTimer( hWnd, 1 );
  24.                              wsprintf( szErrMsg,
  25.                                        "Cannot create timer %d", i + 1);
  26.                              MessageBox( hWnd, szErrMsg, "Error", MB_OK );
  27.                              break;
  28.                          }
  29.                          iInterval+=100;
  30.                       }
  31.                    }
  32.                    break;
  33.                    case IDM_EXIT:
  34.                       DestroyWindow(hWnd);
  35.                       break;
  36.                }
  37.                break;
  38.        case WM_DESTROY:
  39.                PostQuitMessage(0);
  40.                break;
  41.        default:
  42.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  43.     }
  44.     return (NULL);
  45. }